<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>宅急送-登陆</title>
	<link rel="stylesheet" href="/resources/css/cssLogin/style.css" />
	<script type="text/javascript" src="/resources/layui/layui.all.js"></script>
	<script src="/resources/js/function/Local.js"></script>
	<script src="/resources/js/function/Session.js"></script>
<body>
<div class="login-container">
	<h1>宅急送-登陆</h1>

	<form  class="layui-form" id="loginForm" lay-filter="logins">
		<div>
			<input type="text" name="user" class="username" placeholder="用户名" autocomplete="off"/>
		</div>
		<div>
			<input type="password" name="password" class="password" placeholder="密码" oncontextmenu="return false" onpaste="return false" />
		</div>
		<div class="layui-form-item">
			<button lay-submit lay-filter="logins" class="layui-btn">立即登录</button>
		</div>
	</form>

	<a href="register.html">
		<button type="button" class="register-tis">还有没有账号？</button>
	</a>

</div>

<script src="/resources/js/jsLogin/jquery.min.js"></script>
<script src="/resources/js/jsLogin/common.js"></script>
<!--背景图片自动更换-->
<script src="/resources/js/jsLogin/supersized.3.2.7.min.js"></script>
<script src="/resources/js/jsLogin/supersized-init.js"></script>
<!--表单验证-->
<script src="/resources/js/jsLogin/jquery.validate.min.js?var1.14.0"></script>
<script src="/resources/js/json2.js"></script>

<script type="text/javascript">
    layui.use(['form','layer','jquery'], function () {
        // 操作对象
        var form = layui.form;
        var $ = layui.jquery;
        form.on('submit(logins)',function (data) {
            console.log(data.field);
            console.log(data.form);
            $.ajax({
                url:new Local().base_url + '/WebPage/logins',
                data:data.field,
                dataType:'json',
                type:'get',
                success:function (d) {
                    if (d.code == 0){
                        //放入本地存储
                        sessionStorage.setItem(new Session().user_login,JSON.stringify(d.data))
                        layer.msg('登录成功！', {
                            icon: 1,
                            time: 1000 //2秒关闭（如果不配置，默认是3秒）
                        }, function(){
                            location.href = "Home.html";
                        });
                    }else{
                        layer.msg(d.msg);
                    }
                }
            });
            return false;
        })

    });
</script>


</body>
</html>